package com.xiaoxu.dao;

import com.xiaoxu.damain.UserData;
import com.xiaoxu.damain.Userinfo;
import org.apache.catalina.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.Date;
import java.util.List;

@Mapper
public interface UserDao {
    @Select("SELECT * FROM user_info WHERE user_name=#{user_name} and user_password=#{user_password}")
    public UserData getALL(UserData logininfo);

    @Insert("INSERT INTO user_info (user_name,user_password,user_birthday,user_gender,user_telephone,user_createdate) VALUES(#{user_name},#{user_password},#{user_birthday},#{user_gender},#{user_telephone},#{user_createdate})")
    public Boolean insertUser(UserData reginfo);

    @Select("SELECT user_createdate FROM user_info WHERE user_name=#{user_name}")
    public Date userdate(String username);

    @Insert("INSERT INTO meber_info SELECT * FROM user_info WHERE user_name=#{user_name}")
    public Boolean insertMeber(String username);

    @Update("UPDATE user_info SET user_name=#{user_name},user_birthday=#{user_birthday},user_gender=#{user_gender},user_telephone=#{user_telephone} WHERE user_name=#{user_name}")
    public Boolean userEdit(Userinfo userdata);
}
